home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
recent2
/
yamtools.lha
/
yamtools1.4
/
YAMTOOLS.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-03-28
|
80KB
|
2,190 lines
/******************************************************************************/
/* */
/* YAMTOOLS */
/* Copyright ©1997 by Dick Whiting */
/* */
/*----------------------------------------------------------------------------*/
/* */
/* Standard Disclaimer: I wrote it, it works for me, I don't guarantee */
/* that it will do anything productive for anyone else, etc. etc. ;-) */
/* */
/*HOWEVER, if you DO find a use for it: I homeschool my kids and they */
/*would love a postcard from where EVER you live. */
/* */
/*Instant GEOGRAPHY lesson;) */
/* */
/* */
/*POSTCARDS: Dick Whiting */
/* 28590 S. Beavercreek Rd. */
/* Mulino, Oregon 97042 */
/* USA */
/* */
/*----------------------------------------------------------------------------*/
/* */
/* Address Bug Reports or Comments to: */
/* Dick Whiting <dwhiting@europa.com> */
/* 28 March 1997 */
/* */
/******************************************************************************/
/*
$VER: 1.4 Copyright ©1997 by Dick Whiting
$AUTHOR: Dick Whiting
$DESCRIPTION: Add-on Tools for Marcel Beck's wonderful YAM
*/
options results
options failat 21
subrtn=''
parm=''
rest=''
parse arg subrtn parm rest
/******************************************************************************/
/* MUIREXX TAGS & VARIABLES */
/******************************************************************************/
Application_AboutMUI = 0x8042d21d
Application_OpenConfigWindow = 0x804299ba
MUIA_Application_Author = 0x80424842
MUIA_Application_Base = 0x8042e07a
MUIA_Application_Copyright= 0x8042ef4d
MUIA_Application_Description=0x80421fc6
MUIA_Application_Title = 0x804281b8
MUIA_Application_Version = 0x8042b33f
MUIA_Background = 0x8042545b
MUIA_CycleChain = 0x80421ce7
MUIA_Disabled = 0x80423661
MUIA_Draggable = 0x80420b6e
MUIA_DrawersOnly = 0x8008002F
MUIA_Dropable = 0x8042fbce
MUIA_Font = 0x8042be50
MUIA_Frame = 0x8042ac64
MUIA_HorizWeight = 0x80426db9
MUIA_Group_Columns = 0x8042f416
MUIA_Group_SameSize = 0x80420860
MUIA_List_Active = 0x8042391c
MUIA_List_DragSortable = 0x80426099
MUIA_List_Entries = 0x80421654
MUIA_List_Format = 0x80423c0a
MUIA_List_InsertPosition = 0x8042d0cd
MUIA_List_Quiet = 0x8042d8c7
MUIA_List_ShowDropMarks = 0x8042c6f3
MUIA_Listview_DoubleClick = 0x80424635
MUIA_Listview_DragType = 0x80425cd3
MUIA_Listview_MultiSelect = 0x80427e08
MUIA_Listview_SelectChange= 0x8042178f
MUIA_Menuitem_Shortcut = 0x80422030
MUIA_Menuitem_Title = 0x804218be
MUIA_Numeric_Max = 0x8042d78a
MUIA_Numeric_Min = 0x8042e404
MUIA_Numeric_Default = 0x804263e8
MUIA_Scrollgroup_FreeHoriz =0x804292f3
MUIA_Selected = 0x8042654b
MUIA_ShowMe = 0x80429ba8
MUIA_String_AdvanceOnCR = 0x804226de
MUIA_VertWeight = 0x804298d0
MUIA_Weight = 0x80421d1f
MUIA_Window_DepthGadget = 0x80421923
MUIA_Window_DragBar = 0x8042045d
MUIA_Window_ActiveObject = 0x80427925
MUIA_Window_PublicScreen = 0x804278e4
MUIA_Window_SizeGadget = 0x8042e33d
MUIM_List_Clear = 0x8042ad89
MUIM_List_GetEntry = 0x804280ec
MUIM_List_NextSelected = 0x80425f17
ASLFR_InitialFile = 0x80080008
ASLFR_InitialDrawer = 0x80080009
TRUE=1
FALSE=0
MUIV_Font_Big = -6
MUIV_Frame_None = 0
MUIV_List_GetEntry_Active = -1
MUIV_List_Insert_Active = -1
MUIV_List_Insert_Bottom = -3
MUIV_List_Insert_Top = 0
MUIV_Listview_DragType_Immediate = 1
MUIV_Listview_MultiSelect_Shifted = 2
MUII_WindowBack = 0
MUIV_Window_ActiveObject_Next = -1
/**************************************************************************/
/* Various values used throughout the various routines */
/**************************************************************************/
aboutlist=TRUE /* show list in about window */
comma=',' /* used in string building */
configheader='YamTools Configuration File -- Copyright by Dick Whiting'
delaytm=20 /* wait time per loop */
emptyconfig='empty'||comma||'none'||comma||'<----available---->'
fontsize='' /* used to change FONT size */
infolines=28 /* number of header lines */
infotitle="YAM Tools Info" /* default title on infomsg */
maxarchs=50000 /* very large number for loop */
missing='.' /* indicate missing value */
showbusy=FALSE /* don't show busy indicator */
shutdown=FALSE /* flag for quitting YAMTOOLS */
timestamp=time('S') /* timestamp for temp files */
goodconfig=TRUE /* assume config good */
Bcolmax=6 /* max number of columns */
Browmax=16 /* maximum rows of buttons */
emptymax=5 /* allow for 5 delete folders in a row -- arbitrary */
/**************************************************************************/
/* Help Messages to display with MUI bubble facility. */
/* */
/* Format is simple: help.ID where ID is the id specified on the MUI */
/* object statement. */
/* Similar approach for accessing the .guide information using the NODE */
/* option on the object statement. */
/* */
/**************************************************************************/
help.ALST='"Select Folders to search\nor run ARexx Program against"'
help.ARLD='"Use to load/reload folder list\nRequired if you add\nor delete folders"'
help.B00= '"Executes ARexx Program defined in Configuration"'
help.CFG4='"Save & Use currently defined configuration to file"'
help.CFG5='"Use currently defined configuration"'
help.CFG6='"Reload & Use last SAVED/LOADED configuration file"'
help.CFG7='"Clear Selected Entry\n(Remove Script)"'
help.CFG9='"Undo LAST edited entry in list"'
help.CFG1='"Label to appear on button"'
help.CFG2='"Type of processing to do\n- See Documentation or press HELP"'
help.CFG3='"ARexx program to execute when button is pressed"'
help.CFGF='"Location of FlashFind program - required"'
help.CFGM='"Current Mail Directory YAM is using - required"'
help.CFGQ='"Location of QuickSort program - required"'
help.CFGC='"Number of columns of buttons for ARexx programs\nChange takes effect after SAVE and RESTART"'
help.CFGR='"Number of rows of buttons for ARexx programs\nChange takes effect after SAVE and RESTART"'
help.CLST='"Double click to edit entry\nDrag&Drop to Sort"'
help.MDIR='"Currently defined Mail Directory - change on Config page"'
help.MLST='"Double click to READ\nSelect for ARexx Execution target"'
help.SLOG='"Match Any (OR logic)\nMatch All (AND logic)\nfor mail searching"'
help.SQUIT='"INTERRUPT will show results upto this point\nABORT stops ALL processing"'
help.SRC1='"Enter strings to Search for"'
help.SRC2='"Enter strings to Search for"'
help.SRC3='"Enter strings to Search for"'
help.SRCA='"Searches in ALL lines of mail for search strings"'
help.SRCF='"Searches From: Reply-To: Sender:\nlines in mail for search strings"'
help.SRCM='"Searches NON-header\nlines in mail for search strings"'
help.SRCS='"Searches Subject:\nlines in mail for search strings"'
help.SRCT='"Searches To: CC:\nlines in mail for search strings"'
help.SRCX='"Start the Search"'
help.STEXT='"Information Message\nRead it;)"'
/**************************************************************************/
/* Pointers into the YamTools.guide documentation */
/**************************************************************************/
node.ALST='4.1.'
node.ARLD='4.1.'
node.B00='6.2.'
node.CFG4='6.2.'
node.CFG5='6.2.'
node.CFG6='6.2.'
node.CFG7='6.2.'
node.CFG9='6.2.'
node.CFG1='6.2.'
node.CFG2='6.2.'
node.CFG3='6.2.'
node.CFGF='6.1.'
node.CFGM='6.1.'
node.CFGQ='6.1.'
node.CFGC='6.2.'
node.CFGR='6.2.'
node.CLST='6.2.'
node.MDIR='6.1.'
node.MLST='5.1.'
node.SLOG='4.3.'
node.SQUIT='7.2.'
node.SRC1='4.3.'
node.SRC2='4.3.'
node.SRC3='4.3.'
node.SRCA='4.3.'
node.SRCF='4.3.'
node.SRCM='4.3.'
node.SRCS='4.3.'
node.SRCT='4.3.'
node.SRCX='4.3.'
node.STEXT='7.2.'
/**************************************************************************/
/* */
/* Main Logic Routine */
/* */
/**************************************************************************/
Address YAMTOOLS
Call CheckYam /* No YAM-no sense running */
if subrtn~='' then do /* check vars nth time */
getvar YAMTOOLSDEBUG /* see if we're debugging */
debug=result
getvar YAMTOOLSROWS /* number of rows of buttons */
Brows=result
getvar YAMTOOLSCOLS /* number of cols of buttons */
Bcols=result
end
if debug~=TRUE then debug=FALSE
if debug then say 'subrtn='subrtn
if debug then say 'parm='parm
if debug then say 'rest='rest
Select
when subrtn='' then do /* first time - setup window */
Call LoadConfig /* load config or defaults */
setvar YAMTOOLSROWS Brows /* button rows for this run */
setvar YAMTOOLSCOLS Bcols /* button cols for this run */
Call EnsureLibs /* make sure all libs present */
Call ValidateConfig /* check config options */
if goodconfig then do /* found a valid config-use it*/
Call GetArchList /* get all folder info */
Call ExpandAssigns /* change assigns to vols */
Call GetVolume /* change devs to vols */
Call CheckArchs /* make sure all exist */
Call LoadArchList /* build & show folder list */
window ID YTINF CLOSE /* close info window */
end
else do /* invalid or not found */
group ID YTPGS LABELS 'Config'
errmsg='Configuration File not Found or has errors\nPlease enter information\nand SAVE'
Call ErrorMsg
end
end
when subrtn='RESCAN' then do /* reload folder list */
Call ClrArchList /* clear list in preparation */
Call GetArchList /* get all folder info */
Call ExpandAssigns /* change assigns to vols */
Call GetVolume /* change devs to vols */
Call CheckArchs /* make sure all exist */
Call LoadArchList /* build & show folder list */
window ID YTINF CLOSE /* close info window */
end
when subrtn='SETALL' then Call SetAllCheck /* toggle checkmarks */
when subrtn='READMAIL' then Call ReadMail /* read selected mail*/
when subrtn='BUTTON' then Call DoRexxButton /* execute a button */
when subrtn='CONFIGEDIT' then Call ConfigEdit /* modify config */
when subrtn='ABOUT' then Call AboutProgs /* show About info */
when subrtn='LISTMAIL' then Call ListMail /* all mail in folder*/
when subrtn='SEARCH' then Call SearchArchs /* do the searches */
otherwise nop /* never happen ;) */
end
exit
/******************************************************************************/
/* MUIREXX WINDOW DEFINITION */
/******************************************************************************/
BuildWindow:
window ID YTWIN COMMAND '"quit"' PORT YAMTOOLS TITLE '"YAM Tools"',
ATTRS MUIA_Window_PublicScreen screen
menu LABEL '"Project"'
menu LABEL '"About..."'
item COMMAND '"YamTools.rexx ABOUT YAMTOOLS"' LABEL '"YamTools"'
item COMMAND '"YamTools.rexx ABOUT YAM"' LABEL '"YAM"'
item COMMAND '"YamTools.rexx ABOUT MUIREXX"' LABEL '"MuiRexx"'
item COMMAND '"method 'Application_AboutMUI' 0"' PORT YAMTOOLS LABEL '"MUI"'
endmenu
item ATTRS MUIA_Menuitem_Title '-1'
menu LABEL '"Settings"'
item COMMAND '"method 'Application_OpenConfigWindow'"' PORT YAMTOOLS LABEL '"MUI..."'
endmenu
item ATTRS MUIA_Menuitem_Title '-1'
item COMMAND '"YamTools.rexx CONFIGEDIT SAVE"' ATTRS MUIA_Menuitem_Shortcut 'S' LABEL '"Save"'
item COMMAND '"YamTools.rexx CONFIGEDIT SAVEAS"' ATTRS MUIA_Menuitem_Shortcut 'W' LABEL '"SaveAs..."'
item COMMAND '"YamTools.rexx CONFIGEDIT READ"' ATTRS MUIA_Menuitem_Shortcut 'O' LABEL '"Open..."'
item ATTRS MUIA_Menuitem_Title '-1'
item COMMAND '"quit"' PORT YAMTOOLS ATTRS MUIA_Menuitem_Shortcut 'Q' LABEL '"Quit"'
endmenu
group ID YTPGS LABELS '"Folder List,Mail List,Config"' REGISTER
/* Folder List Page */
group
group HORIZ
group
label DOUBLE '"Mail Directory:"'
endgroup
group
text ID MDIR HELP help.MDIR NODE node.MDIR
endgroup
endgroup
group HORIZ MUIA_VertWeight 200 MUIA_HorizWeight 100
group
list ID ALST TITLE '"\033bYam Folder,\033bCount,,"',
COMMAND '"YamTools.rexx LISTMAIL %s"' HELP help.ALST NODE node.ALST,
INSERT NODUP ATTRS MUIA_Listview_MultiSelect MUIV_Listview_MultiSelect_Shifted,
MUIA_List_Format '"MAXWIDTH=75 MINWIDTH=-1 WEIGHT=75 P=\033l BAR,MAXWIDTH=25 MINWIDTH=-1 WEIGHT=25 P=\033r,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0"'
button ID ARLD COMMAND '"YamTools.rexx RESCAN"',
HELP help.ARLD NODE node.ARLD PRESS LABEL "Load Folder List"
endgroup
group FRAME MUIA_HorizWeight 100
label '"\033c\033bSearch Types of Lines"'
group HORIZ
group HORIZ
group
label DOUBLE '"\033lFROM:"'
label DOUBLE '"\033lTO:"'
endgroup
group
check ID SRCF COMMAND '"YamTools.rexx SETALL SRCF"',
HELP help.SRCF NODE node.SRCF ATTRS MUIA_Selected FALSE
check ID SRCT COMMAND '"YamTools.rexx SETALL SRCT"',
HELP help.SRCT NODE node.SRCT ATTRS MUIA_Selected FALSE
endgroup
endgroup
group HORIZ
group
label DOUBLE '"\033lSUBJECT:"'
label DOUBLE '"\033lTEXT:"'
endgroup
group
check ID SRCS COMMAND '"YamTools.rexx SETALL SRCS"',
HELP help.SRCS NODE node.SRCS ATTRS MUIA_Selected FALSE
check ID SRCM COMMAND '"YamTools.rexx SETALL SRCM"',
HELP help.SRCM NODE node.SRCM ATTRS MUIA_Selected FALSE
endgroup
endgroup
endgroup
group HORIZ
label DOUBLE '"\033lALL Lines:"'
check ID SRCA COMMAND '"YamTools.rexx SETALL SRCA"',
HELP help.SRCA NODE node.SRCA ATTRS MUIA_Selected TRUE
endgroup
group
group HORIZ
group
radio ID SLOG HELP help.SLOG NODE node.SLOG,
LABELS '"Match Any,Match All"'
endgroup
endgroup
group
space HORIZ 150
label '"\033l\033bEnter Search Strings:"'
string ID SRC1 HELP help.SRC1 NODE node.SRC1,
ATTRS MUIA_CycleChain TRUE,
MUIA_String_AdvanceOnCR TRUE,
CONTENT ''
string ID SRC2 HELP help.SRC2 NODE node.SRC2,
ATTRS MUIA_CycleChain TRUE,
MUIA_String_AdvanceOnCR TRUE,
CONTENT ''
string ID SRC3 HELP help.SRC3 NODE node.SRC3,
ATTRS MUIA_CycleChain TRUE,
MUIA_String_AdvanceOnCR TRUE,
CONTENT ''
endgroup
group
button ID SRCX HELP help.SRCX NODE node.SRCX,
COMMAND '"YamTools.rexx SEARCH"',
PRESS ATTRS MUIA_CycleChain TRUE MUIA_Disabled FALSE,
LABEL 'Search'
endgroup
endgroup
endgroup
endgroup
endgroup
/* Mail List Page */
group ATTRS MUIA_HorizWeight 100
list ID MLST COMMAND '"YamTools.rexx READMAIL %s"',
HELP help.MLST NODE node.MLST,
TITLE '"\033bYam Folder,\033bFrom,\033bSubject,\033bTo:,,,"',
INSERT NODUP ATTRS MUIA_Listview_MultiSelect MUIV_Listview_MultiSelect_Shifted,
MUIA_List_Format '"BAR,BAR,BAR,,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0,WEIGHT=0 MAXWIDTH=0 MINWIDTH=0"'
endgroup
/* Configuration Page */
group
group FRAME
group HORIZ
group
label DOUBLE '\033b\033lMail Directory:'
endgroup
group
popasl ID CFGM HELP help.CFGM NODE node.CFGM,
ATTRS MUIA_DrawersOnly TRUE,
MUIA_CycleChain TRUE,
MUIA_String_AdvanceOnCR TRUE
endgroup
endgroup
group HORIZ
group
label DOUBLE '\033b\033lFlashFind:'
endgroup
group
popasl ID CFGF HELP help.CFGF NODE node.CFGF,
ATTRS MUIA_CycleChain TRUE,
MUIA_String_AdvanceOnCR TRUE
endgroup
group
label DOUBLE '\033b\033lQuickSort:'
endgroup
group
popasl ID CFGQ HELP help.CFGQ NODE node.CFGQ,
ATTRS MUIA_CycleChain TRUE,
MUIA_String_AdvanceOnCR TRUE
endgroup
endgroup
endgroup
group HORIZ
group ATTRS MUIA_HorizWeight 300 MUIA_VertWeight 200
list ID CLST TITLE '"\033bLabel,\033bType,\033bCommand"',
HELP help.CLST NODE node.CLST,
DROP INSERT PRESS COMMAND '"YamTools.rexx CONFIGEDIT EDIT %s"',
ATTRS MUIA_Listview_DragType MUIV_Listview_DragType_Immediate,
MUIA_List_DragSortable TRUE MUIA_List_ShowDropMarks TRUE,
MUIA_Listview_DoubleClick TRUE,
MUIA_List_Format '"BAR,BAR,"'
endgroup
group
button ID CFG4 COMMAND '"YamTools.rexx CONFIGEDIT SAVE"',
HELP help.CFG4 NODE node.CFG4 PRESS LABEL 'SAVE'
button ID CFG5 COMMAND '"YamTools.rexx CONFIGEDIT USE"',
HELP help.CFG5 NODE node.CFG5 PRESS LABEL 'USE'
button ID CFG6 COMMAND '"YamTools.rexx CONFIGEDIT RELOAD"',
HELP help.CFG6 NODE node.CFG6 PRESS LABEL 'RELOAD'
space
button ID CFG7 COMMAND '"YamTools.rexx CONFIGEDIT CLEAR"',
HELP help.CFG7 NODE node.CFG7 PRESS LABEL 'CLEAR'
button ID CFG9 COMMAND '"YamTools.rexx CONFIGEDIT UNDO"',
HELP help.CFG9 NODE node.CFG9 PRESS LABEL 'UNDO'
endgroup
endgroup
group FRAME
group HORIZ
group
label DOUBLE '\033bLabel:'
endgroup
group
string ID CFG1 COMMAND '"YamTools.rexx CONFIGEDIT UPDATE"',
HELP help.CFG1 NODE node.CFG1,
ATTRS MUIA_CycleChain TRUE,
MUIA_String_AdvanceOnCR TRUE,
CONTENT ''
endgroup
group
label DOUBLE '\033bType:'
endgroup
group
cycle ID CFG2 COMMAND '"YamTools.rexx CONFIGEDIT UPDATE"',
HELP help.CFG2 NODE node.CFG2,
ATTRS MUIA_CycleChain TRUE,
MUIA_String_AdvanceOnCR TRUE,
LABELS 'Mail,Folder,Once'
endgroup
endgroup
group HORIZ
group
label DOUBLE '\033b\033lARexx:'
endgroup
group
popasl ID CFG3 COMMAND '"YamTools.rexx CONFIGEDIT UPDATE"',
HELP help.CFG3 NODE node.CFG3,
ATTRS MUIA_CycleChain TRUE,
MUIA_String_AdvanceOnCR TRUE,
CONTENT 'YAM:REXX'
endgroup
group
label DOUBLE '\033bCols:'
endgroup
group
popslider ID CFGC HELP help.CFGC NODE node.CFGC,
ATTRS MUIA_Numeric_Default bcols MUIA_Numeric_Max bcolmax MUIA_Numeric_Min 1
endgroup
group
label DOUBLE '\033bRows:'
endgroup
group
popslider ID CFGR HELP help.CFGR NODE node.CFGR,
ATTRS MUIA_Numeric_Default brows MUIA_Numeric_Max browmax MUIA_Numeric_Min 1
endgroup
endgroup
endgroup
endgroup
endgroup
/* Command Buttons */
group FRAME SCROLL ATTRS MUIA_Scrollgroup_FreeHoriz FALSE
group ATTRS MUIA_Group_Columns bcols
do i=1 to (Brows*Bcols)
bnum=right(i,2,'0')
bid='B'||right(i,2,'0')
button ID bid COMMAND '"YamTools.rexx BUTTON 'bnum '"' PRESS HELP help.B00 NODE node.B00
end
endgroup
endgroup
endwindow
application ATTRS MUIA_Application_Author '"Dick Whiting"',
MUIA_Application_Base '"YAMTOOLS"',
MUIA_Application_Copyright '"Copyright ©1997 by Dick Whiting"',
MUIA_Application_Description '" Add-On Tools For YAM"',
MUIA_Application_Title '"YamTools"',
MUIA_Application_Version '"Version 1.4"'
Return
/**************************************************************************/
/* Make sure YAM is running & visible. */
/**************************************************************************/
CheckYAM:
if ~show('p','YAM') then do
errmsg='You need YAM running to use YAMTOOLS'
if subrtn='' then do
shutdown=TRUE
end
else do
shutdown=FALSE
end
Call ErrorMsg
end
Address YAM 'show' /* uniconify YAM's screen */
Address YAM 'info SCREEN' /* get YAM's screen */
screen=result
if screen='' then screen='Workbench'
Return
/**************************************************************************/
/* */
/* Make sure that we have all the libs we need: */
/* RexxSupport */
/* QuickSort */
/* */
/**************************************************************************/
EnsureLibs:
if ~show('L','rexxsupport.library') then do
addlib('rexxsupport.library',0,-30)
end
if ~show('P','QuickSortPort') then do
address Command "run >nil: "qsortprog
do i = 1 to 10
if ~show('P','QuickSortPort') then foo=delay(delaytm)
else leave i
end
end
if show('P','QuickSortPort') then do
call addlib('QuickSortPort',-30)
end
else do
errmsg='Unable to find QuickSort -- check installation instructions'
signal ErrorMsg
end
Return
/**************************************************************************/
/* Expand Assign Names for YAM folders */
/* */
/* FlashFind reports back on the volume:directory/subdir/file so to make */
/* sure we can accurately identify and match files, we'll change assigns */
/* to this format. */
/* */
/**************************************************************************/
ExpandAssigns:
assign.=missing
assign.0=0
assignfile='T:YTassigns.'||timestamp
text ID MDIR
maildir=result
if maildir='' then do
errmsg='You MUST set Mail Directory in Configuration'
signal ErrorMsg
end
Address Command "assign > "assignfile
foo=delay(delaytm*3)
goodopen=open('IN',assignfile,'R')
if goodopen then do
do until eof('IN')
linein=readln('IN')
if pos('Directories:',linein)>0 then do
do until eof('IN')
linein=readln('IN')
if linein='' then signal CloseAssign
assign.0=1+assign.0
aptr=assign.0
assign.aptr=word(linein,1)
avol=word(linein,2)
avol=translate(avol,' ','<>[]')
avol=strip(avol)
assign.aptr.1=avol
end
end
end
end
else do
errmsg='Couldnt open assignfile: 'assignfile
Call ErrorMsg
end
CloseAssign:
result=close('IN')
if pos(':',maildir)>0 then do
testvol=substr(maildir,1,pos(':',maildir)-1)
restvol=substr(maildir,pos(':',maildir)+1)
do j=1 to assign.0
if upper(assign.j)=upper(testvol) then do
maildir=assign.j.1
if right(maildir,1)~=':' then do
if restvol~='' then maildir=maildir||'/'||restvol
end
leave j
end
end
end
do i=1 to finfo.0
if pos(':',finfo.i.1.1)>0 then do
testvol=substr(finfo.i.1.1,1,pos(':',finfo.i.1.1)-1)
restvol=substr(finfo.i.1.1,pos(':',finfo.i.1.1)+1)
do j=1 to assign.0
if upper(assign.j)=upper(testvol) then do
testvol=assign.j.1
if right(testvol,1)~=':' then do
if restvol~='' then testvol=testvol||'/'||restvol
end
finfo.i.1.1=testvol
leave j
end
end
end
else do
if right(maildir,1)=':' then finfo.i.1.1=maildir||finfo.i.1.1
else finfo.i.1.1=maildir||'/'||finfo.i.1.1
end
end
if exists(assignfile) then do
Address Command 'Delete 'assignfile 'QUIET'
end
Return
/**************************************************************************/
/* Change DEV names to VOLUME names */
/* */
/* FlashFind reports back on the volume:directory/subdir/file so to make */
/* sure we can accurately identify and match files, we'll change device */
/* names to volume names. */
/* */
/**************************************************************************/
GetVolume:
volume.=missing
volume.0=0
volumefile='T:YTvolumes.'||timestamp
Address Command "info > "volumefile
foo=delay(delaytm*3)
goodopen=open('IN',volumefile,'R')
if goodopen then do
do until eof('IN')
linein=readln('IN')
if word(linein,1)='Unit' then do
do until eof('IN')
linein=readln('IN')
if linein='' then signal CloseVolume
volume.0=1+volume.0
vptr=volume.0
volume.vptr=word(linein,1)
if words(linein)>=8 then do
volume.vptr.1=subword(linein,8)
end
end
end
end
end
else do
errmsg='Couldnt open volumefile: 'volumefile
Call ErrorMsg
end
CloseVolume:
result=close('IN')
do i=1 to finfo.0
if pos(':',finfo.i.1.1)>0 then do
testvol=substr(finfo.i.1.1,1,pos(':',finfo.i.1.1)-1)
restvol=substr(finfo.i.1.1,pos(':',finfo.i.1.1)+1)
do j=1 to volume.0
if upper(volume.j)=upper(testvol) then do
testvol=volume.j.1
if right(testvol,1)~=':' then do
if restvol~='' then testvol=testvol||'/'||restvol
end
finfo.i.1.1=testvol
leave j
end
end
end
else do
if right(maildir,1)=':' then finfo.i.1.1=maildir||finfo.i.1.1
else finfo.i.1.1=maildir||'/'||finfo.i.1.1
end
end
if exists(volumefile) then do
Address Command 'Delete 'volumefile 'QUIET'
end
Return
/******************************************************************************/
/* */
/* Make sure that all of the folders actually exist as directories. */
/* They might NOT if the user sets the wrong MAILDIR: in the configuration. */
/* */
/******************************************************************************/
CheckArchs:
do i=1 to finfo.0
if ~exists(finfo.i.1.1) then do
errmsg='"One of more folders do not exist as directory names.\nCheck that MailDir is specified correctly and reload Folder list"'
shutdown=FALSE
window ID YTINF CLOSE
Call ErrorMsg
end
end
Return
/******************************************************************************/
/* */
/* Ask YAM for each folder name, its number, and its path. */
/* Remember to set folder back to original before leaving. */
/* */
/******************************************************************************/
GetArchList:
infotext='Getting Folder List'
infobuttons=''
showbusy=TRUE
Call InfoWindow
Address YAM 'getfolderinfo number'
origfolder=result
idx=0
emptycnt=0 /* allow for 5 deleted in a row */
Do i=0 to maxarchs
Address YAM 'setfolder ' i
sfrc=rc
if sfrc=0 then do
idx=idx+1
Address YAM 'getfolderinfo number'
finfo.idx=result
Address YAM 'getfolderinfo name'
finfo.idx.1=result
/* say 'i='i 'idx='idx 'folder number='finfo.idx 'name='finfo.idx.1 */
Address YAM 'getfolderinfo path'
finfo.idx.1.1=result
Address YAM 'getfolderinfo max'
finfo.idx.1.1.1=result
emptycnt=0
end
else do
/* say 'i='i 'idx='idx 'sfrc='sfrc 'emptycnt='emptycnt */
emptycnt=emptycnt+1
if emptycnt>=emptymax then leave i
end
end
finfo.0=idx
Address YAM 'setfolder ' origfolder
Return
/******************************************************************************/
/* Read Config File */
/* If the config file is not found then use internal defaults, force user to */
/* config page, and pop up message to edit and save. If the default config */
/* file is found then use it and scan archive list. Save the name as a var */
/* whenever a new file is loaded for reference by future SAVE,RELOAD cmds. */
/* */
/******************************************************************************/
LoadConfig:
if debug then say 'entered LoadConfig parm='parm
if parm='' then configfile='YAM:REXX/YamTools.config'
else configfile=parm
setvar YAMTOOLSCONFIG configfile
config.=missing
config.0=0
goodconfig=TRUE
maildir=missing
scanprog=missing
qsortprog=missing
brows=missing
bcols=missing
goodopen=open('IN',configfile,'R')
if goodopen then do
linein=readln('IN')
if linein~=configheader then do
infomsg='This is NOT a YamTools Configuration File\nSelect one that is:)'
Call InfoMsg
result=close('IN')
goodconfig=FALSE
getvar OLDYTCONFIG
configfile=result
setvar YAMTOOLSCONFIG configfile
signal LoadConfigEnd
end
do until eof('IN')
linein=readln('IN')
linein=strip(linein)
select
when substr(linein,1,2)='/*' then iterate
when linein='' then iterate
when upper(word(linein,1))='BROWS' then Brows=word(linein,2)
when upper(word(linein,1))='BCOLS' then Bcols=word(linein,2)
when upper(word(linein,1))='MAILDIR' then maildir=word(linein,2)
when upper(word(linein,1))='SCANPROG' then scanprog=word(linein,2)
when upper(word(linein,1))='QSORTPROG' then qsortprog=word(linein,2)
otherwise do
config.0=1+config.0
cptr=config.0
parse var linein config.cptr ',' config.cptr.1 ',' config.cptr.1.1
end
end
end
result=close('IN')
end
else do
Brows=3
Bcols=6
maildir='YAM:'
scanprog='C:FlashFind'
qsortprog='SYS:Rexxc/QuickSort'
Call BuildWindow
text ID MDIR LABEL maildir
popasl ID CFGM CONTENT maildir
popasl ID CFGF CONTENT scanprog
popasl ID CFGQ CONTENT qsortprog
do i=0 to (Brows*Bcols)-1
list ID CLST INSERT POS MUIV_List_Insert_Bottom STRING emptyconfig
end
list ID CLST POS MUIV_List_Insert_Top STRING emptyconfig
goodconfig=FALSE
signal LoadConfigEnd
end
if Brows=missing then Brows=3
if Bcols=missing then Bcols=6
Call BuildWindow
if maildir=missing then do
maildir='YAM:'
text ID MDIR LABEL maildir
popasl ID CFGM CONTENT maildir
goodconfig=FALSE
signal LoadConfigEnd
end
else do
text ID MDIR LABEL maildir
popasl ID CFGM CONTENT maildir
end
if scanprog=missing then do
scanprog='C:FlashFind'
popasl ID CFGF CONTENT scanprog
goodconfig=FALSE
signal LoadConfigEnd
end
else do
popasl ID CFGF CONTENT scanprog
end
if qsortprog=missing then do
qsortprog='SYS:Rexxc/QuickSort'
popasl ID CFGQ CONTENT qsortprog
goodconfig=FALSE
signal LoadConfigEnd
end
else do
popasl ID CFGQ CONTENT qsortprog
end
do i=1 to config.0
if i> Brows*Bcols then do
infomsg='Too Many Button Entries in 'configfile '\nSome buttons may be lost'
Call InfoMsg
goodconfig=FALSE
signal LoadConfigEnd
end
j=i-1
liststr=config.i||comma||config.i.1||comma||config.i.1.1
list ID CLST POS j STRING liststr
bname=config.i
if bname='empty' then bname=''
bnum='B'||right(i,2,'0')
button ID bnum LABEL bname
end
k=i /* copy counter */
do i=k to Brows*Bcols /* fill any empty slots */
j=i-1
list ID CLST INSERT POS j STRING emptyconfig
end
list ID CLST POS MUIV_List_Insert_Top
liststr=result
list ID CLST POS MUIV_List_Insert_Top STRING liststr
LoadConfigEnd:
Return
/******************************************************************************/
/* Edit Config Options */
/* */
/* Handle changing of ARexx command buttons, mail directory, flashfind, and */
/* qsort locations. Process SAVE,USE,RELOAD,CLEAR and a single level of UNDO. */
/* */
/******************************************************************************/
ConfigEdit:
if debug then say 'entered ConfigEdit'
if debug then say 'parm='parm
list ID CLST MUIA_List_Active
cpos=result
if debug then say 'cpos='cpos
string ID CFG1
cfgS1=result
cycle ID CFG2
cfgS2=result
popasl ID CFG3
cfgS3=result
select
when parm='UPDATE' then do
liststr=cfgS1||comma||cfgS2||comma||cfgS3
list ID CLST POS cpos STRING liststr
end
when parm='EDIT' then do
parse var rest oldcfgS1 ',' oldcfgS2 ',' oldcfgS3
oldcfgS1=strip(oldcfgS1)
oldcfgS2=strip(oldcfgS2)
oldcfgS3=strip(oldcfgS3)
liststr='"'||oldcfgS1||comma||oldcfgS2||comma||oldcfgs3||'"'
setvar ytoldcfg liststr
if substr(oldcfgS1,1,5)='empty' then oldcfgs1=''
string ID CFG1 CONTENT oldcfgS1
if oldcfgS2='none' then oldcfgs2=''
cycle ID CFG2 LABELS oldcfgS2
if pos('--available--',oldcfgS3)>0 then oldcfgS3='YAM:rexx'
popasl ID CFG3 CONTENT oldcfgS3
end
when parm='CLEAR' then do
list ID CLST POS cpos STRING emptyconfig
end
when parm='USE' then do
Call ValidateConfig
Call UpdateButtons
Call EnsureLibs
end
when parm='SAVE' then do
Call ValidateConfig
Call UpdateButtons
Call SaveConfig
Call EnsureLibs
end
when parm='SAVEAS' then do
Call AskConfig
Call ValidateConfig
Call UpdateButtons
Call SaveConfig
Call EnsureLibs
end
when parm='RELOAD' then do
getvar YAMTOOLSCONFIG
parm=result
Call LoadConfig
Call ValidateConfig
Call EnsureLibs
end
when parm='READ' then do
Call AskConfig
getvar YAMTOOLSCONFIG
parm=result
Call LoadConfig
Call ValidateConfig
Call EnsureLibs
end
when parm='UNDO' then do
getvar ytoldcfg
oldcfg=result
parse var oldcfg oldcfgS1 ',' oldcfgS2 ',' oldcfgS3
liststr=oldcfgS1||comma||oldcfgS2||comma||oldcfgS3
list ID CLST POS cpos STRING liststr
end
otherwise do
if debug then say 'otherwise in CONFIGEDIT'
end
end
Return
/******************************************************************************/
/* */
/* Ask user for name of configuration file to either READ or SAVEAS */
/* */
/******************************************************************************/
AskConfig:
getvar YAMTOOLSCONFIG
configfile=result
setvar OLDYTCONFIG configfile
select
when lastpos('/',configfile)>0 then do
figfile=substr(configfile,lastpos('/',configfile)+1)
figdir=substr(configfile,1,lastpos('/',configfile)-1)
end
when lastpos(':',configfile)>0 then do
figfile=substr(configfile,lastpos(':',configfile)+1)
figdir=substr(configfile,1,lastpos(':',configfile)-1)
end
otherwise do
figfile='YamTools.config'
figdir='YAM:rexx'
end
end
aslrequest ID YTWIN TITLE '"Select File"',
ATTRS ASLFR_InitialDrawer figdir ASLFR_InitialFile figfile
if rc = 0 then do
configfile=result
setvar YAMTOOLSCONFIG configfile
if debug then say 'Configfile from ASLFR='configfile
end
Return
/******************************************************************************/
/* */
/* SAVE configuration file to file pointed at by the MuiRexx YAMTOOLSCONFIG */
/* variable. Very simple format for config file. */
/* */
/******************************************************************************/
SaveConfig:
list ID CLST MUIA_List_Active
cpos=result
getvar YAMTOOLSCONFIG
configfile=result
goodopen=open('OUT',configfile,'W')
if goodopen then do
foo=writeln('OUT',configheader)
popasl ID CFGM
maildir=result
text ID MDIR LABEL maildir
liststr='MAILDIR'||' '||maildir
foo=writeln('OUT',liststr)
popasl ID CFGF
scanprog=result
liststr='SCANPROG'||' '||scanprog
foo=writeln('OUT',liststr)
popasl ID CFGQ
qsortprog=result
liststr='QSORTPROG'||' '||qsortprog
foo=writeln('OUT',liststr)
popslider ID CFGR
xrows=result
liststr='BROWS'||' '||xrows
foo=writeln('OUT',liststr)
popslider ID CFGC
xcols=result
liststr='BCOLS'||' '||xcols
foo=writeln('OUT',liststr)
do i=0 to (Brows*Bcols)-1
j=i+1
list ID CLST POS i
oldcfg=result
parse var oldcfg oldcfgS1 ',' oldcfgS2 ',' oldcfgS3
liststr=oldcfgS1||comma||oldcfgS2||comma||oldcfgS3
foo=writeln('OUT',liststr)
end
result=close('OUT')
end
else do
errmsg='Unable to open Config file for output'
Call ErrorMsg
end
list ID CLST POS cpos
Return
/******************************************************************************/
/* */
/* Validate ALL of the Configuration information. */
/* */
/******************************************************************************/
ValidateConfig:
popasl ID CFGM
maildir=result
if right(maildir,1)='/' then do
maildir=substr(maildir,1,length(maildir)-1)
end
if ~exists(maildir) then do
goodconfig=FALSE
errmsg='"Mail directory: "'||maildir||" does not exist"
Call Errormsg
end
text ID MDIR LABEL maildir
popasl ID CFGM CONTENT maildir
popasl ID CFGF
scanprog=result
if ~exists(scanprog) then do
goodconfig=FALSE
errmsg='"Scan program: "'||scanprog||" does not exist"
Call Errormsg
end
popasl ID CFGQ
qsortprog=result
if ~exists(qsortprog) then do
goodconfig=FALSE
errmsg='"QuickSort program: "'||qsortprog||" does not exist"
Call Errormsg
end
do i=0 to (Brows*Bcols)-1
list ID CLST POS i
oldcfg=result
parse var oldcfg blabel ',' ptype ',' rexxprog
if blabel='empty' then iterate
if ~exists(rexxprog) then do
goodconfig=FALSE
errmsg='"ARexx program: "'||rexxprog||" does not exist"
Call Errormsg
end
if blabel='' then do
goodconfig=FALSE
errmsg='"Label is required for: "'||rexxprog
Call Errormsg
end
end
Return
/******************************************************************************/
/* */
/* Update the labels on the ARexx command buttons to match the current config.*/
/* */
/******************************************************************************/
UpdateButtons:
list ID CLST MUIA_List_Active
cpos=result
do i=0 to (Brows*Bcols)-1
j=i+1
list ID CLST POS i
liststr=result
parse var liststr blabel ',' rest
if blabel='empty' then blabel=''
bid='B'||right(j,2,'0')
button ID bid LABEL blabel
end
list ID CLST POS cpos
Return
/******************************************************************************/
/* */
/* Load the Folder List on page 1 of the YAMTOOLS window. */
/* */
/******************************************************************************/
LoadArchList:
do i=1 to finfo.0
liststr=finfo.i.1||comma||finfo.i.1.1.1||comma||finfo.i.1.1||comma||finfo.i
list ID ALST INSERT POS MUIV_List_Insert_Bottom STRING liststr
end
Return
/******************************************************************************/
/* */
/* Clear all entries in the Folder List. */
/* */
/******************************************************************************/
ClrArchList:
list ID ALST ATTRS MUIA_List_Entries
acnt=result
do i=1 to acnt
list ID ALST POS MUIV_List_Insert_Top STRING
end
Return
/******************************************************************************/
/* */
/* Uncheck ALL if ANY of the others are set to ON. Unset others if user turns */
/* on the ALL lines option. */
/* */
/******************************************************************************/
SetAllCheck:
check ID parm
status=result
if status then do
Select
when parm='SRCA' then do
check ID SRCS ATTRS MUIA_Selected FALSE
check ID SRCF ATTRS MUIA_Selected FALSE
check ID SRCT ATTRS MUIA_Selected FALSE
check ID SRCM ATTRS MUIA_Selected FALSE
end
otherwise do
check ID SRCA ATTRS MUIA_Selected FALSE
end
end
end
Return
/******************************************************************************/
/* Create mail list of all mail in folder. */
/******************************************************************************/
ListMail:
if debug then say 'Entered ListMail:'
aline=parm||rest
if debug then say aline
parse var aline arch ',' size ',' afile ',' anum ',' rest
if debug then say ' arch='arch
if debug then say ' size='size
if debug then say ' anum='anum
if debug then say ' afile='afile
Address YAM "setfolder" anum
Address YAM "getfolderinfo max"
size=result
list ID MLST ATTRS MUIA_List_Entries
mcnt=result
if debug then say 'mcnt='mcnt
if debug then say 'Clearing Mail List '
infotitle='"YAM Tools Search"'
infotext="Loading Mail list..."
infobuttons='"Continue,Interrupt,Abort"'
showbusy=TRUE
Call InfoWindow
do i=1 to mcnt
list ID MLST POS MUIV_List_Insert_Top STRING
end
do i=0 to size-1
mnum=i
Address YAM "setmail" mnum
Address YAM "getmailinfo file"
mpath=result
file=substr(mpath,lastpos('/',mpath)+1) /* just the filename part*/
Address YAM "getmailinfo from"
from=result
if pos('<',from)>1 then from=substr(from,1,pos('<',from)-1)
from=translate(from,' ',',')
Address YAM "getmailinfo subject"
subj=result
subj=translate(subj,' ',',')
Address YAM "getmailinfo to"
mfor=result
mfor=translate(mfor,' ',',')
liststr=arch||comma||from||comma||subj||comma||mfor||comma||mnum||comma||anum||comma||file
if debug then say liststr
list ID MLST INSERT POS MUIV_List_Insert_Bottom STRING liststr
radio ID SQUIT
squitopt=result
select
when squitopt="Interrupt" then leave i
when squitopt="Abort" then do
signal ListMailEnd
end
otherwise nop
end
end
group ID YTPGS LABELS '"Mail List"'
ListMailEnd:
window ID YTINF CLOSE
Return
/******************************************************************************/
/* Read mail the user selected. */
/******************************************************************************/
ReadMail:
if debug then say 'Entered ReadMail:'
mline=parm||rest
if debug then say mline
parse var mline arch ',' from ',' subject ',' mfor ','mnum ',' anum ',' file
Address YAM "setfolder" anum
Address YAM "setmail" mnum
Address YAM "getmailinfo file"
mpath=result
if debug then say 'mpath='mpath
if debug then say 'file='file
if pos(file,mpath)=0 then do
infotext='Order of mail in folder has changed\nSearching for mail...'
showbusy=TRUE
infobuttons=""
Call InfoWindow
Address YAM "getfolderinfo max"
mcnt=result
do i=0 to mcnt-1
Address YAM "setmail" i
Address YAM "getmailinfo file"
mpath=result
if pos(file,mpath)~=0 then do
window ID YTINF CLOSE
leave i
end
else mpath=missing
end
end
if mpath~=missing then do
Address Command "sys:Utilities/multiview " mpath "PUBSCREEN="screen
/* Address YAM "mailreply" */
end
else do
window ID YTINF CLOSE
errmsg="This mail has been moved or deleted"
Call ErrorMsg
end
Return
/******************************************************************************/
/* */
/* Determine loop control and then invoke the specified command for each of */
/* folders, directories, mail, or filenames as appropriate. */
/* 2/26/97 Added execute ONCE option. Passes NO information just Calls. */
/* */
/******************************************************************************/
DoRexxButton:
butid='B'||parm
list ID CLST POS parm-1
cmdline=result
if debug then say 'Entered DoRexxButton'
if debug then say 'cmdline='cmdline
parse var cmdline blabel ',' btype ',' bcommand
group ID YTPGS REGISTER
pagename=result
select
when pagename='Config' then do
errmsg='Cannot Execute Buttons from Config Window'
Call ErrorMsg
end
when upper(btype)='ONCE' then do
intcommand="Call '"bcommand"'"
if debug then say 'intcommand='intcommand
interpret intcommand
end
when pagename='Mail List' then do
if upper(btype)='FOLDER' then do
errmsg='This command needs to be run from the folder list'
signal ErrorMsg
end
else do
list ID MLST ATTRS MUIA_List_Entries
mcnt=result
if debug then say 'mcnt='mcnt
infotext="\n\n Starting to process entries \n\n"
showbusy=TRUE
infobuttons='"Continue,Abort"'
Call InfoWindow
do msel=0 to mcnt
list ID MLST
mline=result
if mline='' then leave msel
parse var mline arch ',' from ',' subj ',' mfor ',' mnum ',' anum ',' file
if debug then say 'mline='mline
Address YAM "setfolder" anum
Address YAM "setmail" mnum
Address YAM "getmailinfo file"
mpath=result
infotext="Processing Folder "||arch||"\nMail entry "||mnum+1
text ID STEXT LABEL infotext
if pos(file,mpath)=0 then do
infotext="Order of mail in folder has changed\nSearching for mail..."
text ID STEXT LABEL infotext
Address YAM "getfolderinfo max"
xmcnt=result
do i=0 to xmcnt-1
Address YAM "setmail" i
Address YAM "getmailinfo file"
mpath=result
if pos(file,mpath)~=0 then do
leave i
end
else mpath=missing
end
end
if mpath~=missing then do
intcommand="Call '"bcommand"' '"mpath"'"
if debug then say 'intcommand='intcommand
interpret intcommand
end
else do
infotext="Mail has been deleted or moved\nContinuing with others"
text ID STEXT LABEL infotext
end
radio ID SQUIT
squitopt=result
if squitopt="Abort" then leave msel
end
window ID YTINF CLOSE
end
end
when pagename='Folder List' then do
list ID ALST ATTRS MUIA_List_Entries
acnt=result
infotext="\n\n Starting to process entries \n\n"
showbusy=TRUE
infobuttons='"Continue,Abort"'
Call InfoWindow
do asel=0 to acnt
list ID ALST
aline=result
if aline='' then leave asel
parse var aline arch ',' size ',' file ',' anum ',' rest
if debug then say 'aline='aline
if size=0 then iterate asel
Address YAM "setfolder" anum
if upper(btype)='FOLDER' then do
Address YAM "setmail 0"
infotext="Processing Folder "||arch
text ID STEXT LABEL infotext
intcommand="Call '"bcommand"' '"file"'"
if debug then say 'intcommand='intcommand
interpret intcommand
radio ID SQUIT
squitopt=result
if squitopt="Abort" then leave asel
end
else do
Address YAM "getfolderinfo max"
mcnt=result
do mnum=0 to mcnt-1
Address YAM "setmail" mnum
Address YAM "getmailinfo file"
mpath=result
infotext="Processing Folder "||arch||"\nMail entry "||mnum+1||"/"||mcnt
text ID STEXT LABEL infotext
intcommand="Call '"bcommand"' '"mpath"'"
if debug then say 'intcommand='intcommand
interpret intcommand
radio ID SQUIT
squitopt=result
if squitopt="Abort" then leave asel
end
end
end
window ID YTINF CLOSE
end
otherwise do
infomsg= 'Found otherwise in DoRexxButton'
Call InfoMsg
end
end
Return
/******************************************************************************/
/* Get information from main search screen, scan files for search strings */
/* Build screen list of mail that matches criteria */
/******************************************************************************/
SearchArchs:
ADDRESS YAMTOOLS
popasl ID CFGM
maildir=result
popasl ID CFGF
scanprog=result
popasl ID CFGQ
qsortprog=result
tmpfile="T:ytsearch."||timestamp
timerfile="T:ytwait."||timestamp
sptr=0
srchstr.=missing
srchstr.0=0
Archlist.=missing
Archlist.0=0
Matches.=missing
Matches.0=0
string ID SRC1
sval=result
if sval~='' & sval~='RESULT' then do
srchstr.0=1+srchstr.0
sptr=srchstr.0
srchstr.sptr=sval
srchstr.sptr.1=0
if debug then say srchstr.0 'search string:' srchstr.sptr
end
string ID SRC2
sval=result
if sval~='' & sval~='RESULT' then do
srchstr.0=1+srchstr.0
sptr=srchstr.0
srchstr.sptr=sval
srchstr.sptr.1=0
if debug then say srchstr.0 'search string:' srchstr.sptr
end
string ID SRC3
sval=result
if sval~='' & sval~='RESULT' then do
srchstr.0=1+srchstr.0
sptr=srchstr.0
srchstr.sptr=sval
srchstr.sptr.1=0
if debug then say srchstr.0 'search string:' srchstr.sptr
end
if sptr=0 then do
errmsg="Specify SEARCH strings"
Call ErrorMsg
end
check ID SRCS
srchsubj=result
check ID SRCF
srchfrom=result
check ID SRCT
srchto=result
check ID SRCM
srchmsg=result
check ID SRCA
srchall=result
radio ID SLOG
matchlogic=result
if matchlogic='Match Any' then matchreqs=1
else matchreqs=srchstr.0
list ID ALST ATTRS MUIA_List_Entries
acnt=result
if debug then say 'acnt='acnt
list ID MLST ATTRS MUIA_List_Entries
mcnt=result
if debug then say 'mcnt='mcnt
if debug then say 'Clearing Mail List '
do i=1 to mcnt
list ID MLST POS MUIV_List_Insert_Top STRING
end
button ID SRCX PORT YAMTOOLS ATTRS MUIA_Disabled TRUE
infotitle='"YAM Tools Search"'
infotext="Starting to Search Folders"
infobuttons='"Continue,Interrupt,Abort"'
showbusy=TRUE
Call InfoWindow
do asel=0 to acnt
list ID ALST
aline=result
if aline='' then break
parse var aline arch ',' size ',' file ',' anum ',' rest
text ID STEXT LABEL "Scanning: "arch
if debug then say 'Call SearchArchive for:' aline
if size > 0 then Call SearchArchive
archcnt=asel+1
Archlist.0=archcnt
Archlist.archcnt=arch
Archlist.archcnt.1=anum
Archlist.archcnt.1.1=file
radio ID SQUIT
squitopt=result
select
when squitopt="Interrupt" then leave asel
when squitopt="Abort" then do
signal SearchArchsEnd
end
otherwise nop
end
end
if exists(timerfile) then do
if ~debug then do
Address Command 'Delete ' timerfile 'Quiet'
end
end
if asel=0 then do
errmsg="Select Folders to Search"
Call ReEnableSearch
Call ErrorMsg
end
Call DoScanFile
radio ID SQUIT
if result~="Continue" then do
Call ReEnableSearch
errmsg="Search Interrupted/Aborted"
Call ErrorMsg
end
list ID MLST INSERT POS MUIV_List_Insert_Bottom ATTRS MUIA_List_Quiet TRUE
if debug then say 'starting match archlist to matches'
if Matches.0=0 then do
errmsg="No Matches Found"
Call ReEnableSearch
Call ErrorMsg
end
do i=1 to Archlist.0
do j=1 to Matches.0
if upper(Matches.j.1)=upper(Archlist.i.1.1) then do
Matches.j=Archlist.i
Matches.j.1.1.1=Archlist.i.1
end
end
end
/**************************************************************************/
/* Match of scan results to mail within each folder */
/* */
/* If only 1 match is found in a given folder then we just loop thru the */
/* mail until we find the matching filename. If there is more than 1 in */
/* a specific folder then we loop thru the folder, build an array of info */
/* and then do our matching against the array. This speeds the process up */
/* for both conditions. Remove commas from From:,To:, and Subject: */
/**************************************************************************/
if debug then say "Doing getmailinfo for i=1 to " Matches.0
oldfolder=missing
do i=1 to Matches.0
fptr=i+1
if matches.fptr.1.1.1=missing & matches.i.1.1.1=oldfolder then leave i
if debug then say 'i='i 'matches.0='matches.0
radio ID SQUIT
if result~="Continue" then leave i
Address YAM "setfolder" matches.i.1.1.1
Address YAM "getfolderinfo max"
mailcnt=result
if debug then say 'current/next folders' matches.i.1.1.1 matches.fptr.1.1.1
if matches.fptr.1.1.1~=matches.i.1.1.1 then do
do j=0 to mailcnt-1
Address YAM "setmail" j
Address YAM "getmailinfo file"
mpath=result
if pos(matches.i.1.1,mpath)>0 then do
matches.i.1.1.1.1=j /* number */
Address YAM "getmailinfo from"
from=result
if pos('<',from)>1 then from=substr(from,1,pos('<',from)-1)
matches.i.1.1.1.1.1=translate(from,' ',',') /*from */
Address YAM "getmailinfo subject"
subject=result
matches.i.1.1.1.1.1.1=translate(subject,' ',',') /*subject */
Address YAM "getmailinfo to"
to=result
matches.i.1.1.1.1.1.1.1=translate(to,' ',',') /* To: */
iterate i
end
end
end
else do
oldptr=i
oldfolder=matches.i.1.1.1
tempmail.=missing
tempmail.0=0
if debug then say 'oldptr='oldptr 'oldfolder=oldfolder'
do j=0 to mailcnt-1
k=j+1
tempmail.0=k
Address YAM "setmail" j
Address YAM "getmailinfo file"
tempmail.k=result
end
do newptr=oldptr to matches.0
i=newptr-1
if debug then say 'i='i 'newptr='newptr 'current='matches.newptr.1.1.1 'oldfolder='oldfolder
if matches.newptr.1.1.1~=oldfolder then iterate i
do j=1 to tempmail.0
if pos(matches.newptr.1.1,tempmail.j)>0 then do
matches.newptr.1.1.1.1=j-1 /* number */
Address YAM "setmail" j-1
Address YAM "getmailinfo from"
from=result
if pos('<',from)>1 then from=substr(from,1,pos('<',from)-1)
matches.newptr.1.1.1.1.1=translate(from,' ',',')
Address YAM "getmailinfo subject"
subject=result
matches.newptr.1.1.1.1.1.1=translate(subject,' ',',')
Address YAM "getmailinfo to"
to=result
matches.newptr.1.1.1.1.1.1.1=translate(to,' ',',')
iterate newptr
end
end
end
end
end
/**************************************************************************/
/* Build the Mail List and switch to the Mail List page. */
/**************************************************************************/
if debug then say 'Placing info in MLST'
do i=1 to Matches.0
arch=Matches.i
path=Matches.i.1
file=Matches.i.1.1
anum=Matches.i.1.1.1
mnum=Matches.i.1.1.1.1
from=Matches.i.1.1.1.1.1
subj=Matches.i.1.1.1.1.1.1
mfor=Matches.i.1.1.1.1.1.1.1
liststr=arch||comma||from||comma||subj||comma||mfor||comma||mnum||comma||anum||comma||file
list ID MLST INSERT POS MUIV_List_Insert_Bottom STRING liststr
if debug then say 'match file='file
if debug then say 'match path='path
end
list ID MLST ATTRS MUIA_List_Quiet FALSE
group ID YTPGS LABELS '"Mail List"'
SearchArchsEnd:
ReEnableSearch:
window ID YTINF CLOSE
button ID SRCX HELP help.SRCX NODE node.SRCX COMMAND '"YamTools.rexx SEARCH "',
PRESS ATTRS MUIA_CycleChain TRUE MUIA_Disabled FALSE,
LABEL 'Search'
Return
/******************************************************************************/
/* */
/******************************************************************************/
SearchArchive:
sfile=file||'/'
do j=1 to srchstr.0
if debug then say 'starting 'scanprog sfile srchstr.j
Address Command "run >nil: "scanprog sfile '"'srchstr.j'"' " NH NUM >>"tmpfile
Call WaitScanDone
if debug then say 'finished 'scanprog sfile srchstr.j
radio ID SQUIT
if result~="Continue" then leave j
end
Return
/**************************************************************************/
/* */
/* Scan files with output to a temp file. Read lines back into array. */
/* Sort the array. Sorted array becomes input for further processing. */
/* */
/**************************************************************************/
DoScanFile:
infotext="Building Match List..."
text ID STEXT LABEL infotext
ScanArray.=missing /* stores parsed information from scan prg */
ScanArray.0=0 /* no scan lines yet */
sptr=0 /* counter for array */
Matches.=missing /* array for matches */
Matches.0=0 /* none yet */
matchcnt=0 /* used to determine matches */
olddir =missing /* level break controls */
oldfile=missing /* level break controls */
goodopen=open('IN',tmpfile,'R')
if ~goodopen then do
/* put user notification code/call here */
exit
end
do until eof('IN')
linein=readln('IN')
select
when words(linein)=2 & word(linein,2)='...' then do
fullname=word(linein,1) /* filename with path */
chop=lastpos('/',fullname) /* start of filename */
filename=substr(fullname,chop+1) /* just the filename part*/
dirname=substr(fullname,1,chop-1) /* path info */
end
when words(linein) > 0 then do
linenum=strip(word(linein,1)) /* line number found */
linenum=right(linenum,6,'0') /* put in leading zeros */
text=subword(linein,2) /* remaining string */
sptr=sptr+1 /* increment cnter */
scanarray.0=sptr /* store it */
scanarray.sptr=dirname filename linenum text /* store it */
end
otherwise nop /* should be end of file */
end
end
result=close('IN') /* close the scan file */
if ~debug then do
Address Command 'Delete ' tmpfile 'quiet' /* delete it */
end
if show('L','rexxtricks.library') then do /* use tricks library */
call QSORT(scanarray) /* sort by name, line number */
end
else do /* use QuickSort format */
call QSORT(1, scanarray.0, scanarray) /* sort by name, line number */
end
do i=1 to scanarray.0
dirname=word(scanarray.i,1) /* directory in array */
filename=word(scanarray.i,2) /* filename in array */
linenum=word(scanarray.i,3) /* line number in array */
text=subword(scanarray.i,4) /* remainder of line */
if dirname~=olddir | filename~=oldfile then do
Call TestMatch /* see if we use this one*/
end
type=word(text,1) /* header word ?? */
if srchall=FALSE then do
Call FilterLines /* accept/reject lines */
if skipline then iterate i
end
do j=1 to srchstr.0 /* loop thru search vals */
if pos(upper(srchstr.j),upper(text))>0 then do /* found match */
srchstr.j.1=1 /* mark as found */
end
end
end /* matches do i=1 to scanarray.0 */
Call TestMatch /* test LAST file */
Return
/**************************************************************************/
/* */
/* Need to accept/reject lines based on type. */
/* Easy ones are Subject: From: To: etc. */
/* Assume that if variable type (word 1 of line) ends in ':' not text line*/
/* */
/**************************************************************************/
FilterLines:
skipline=FALSE /* assume good line */
select
when right(type,1)~=':' & srchmsg then nop
when right(type,1)~=':' & srchmsg then nop
when type='Subject:' & srchsubj then nop
when type='From:' & srchfrom then nop
when type='Reply-To:' & srchfrom then nop
when type='Sender:' & srchfrom then nop
when type='To:' & srchto then nop
when type='CC:' & srchto then nop
otherwise skipline=TRUE /* assume we skip it */
end
Return
/**************************************************************************/
/* */
/* Test for match condition and reset the necessary variables. */
/* for 'AND' conditions matchcnt should be the sum of how many searches */
/* for 'OR' any search value found counts as a match */
/* */
/**************************************************************************/
TestMatch:
matchcnt=0 /* reset for new file */
do j=1 to srchstr.0
matchcnt=matchcnt+srchstr.j.1 /* get match counts */
end
if matchcnt>=matchreqs & olddir~=missing then do /* got a match */
Matches.0=1+Matches.0 /* count it */
mptr=matches.0
Matches.mptr.1=olddir /* store directory name */
Matches.mptr.1.1=oldfile /* store file name */
end
olddir=dirname /* copy for next break */
oldfile=filename /* copy for next break */
do j=1 to srchstr.0 /* loop thru search vals */
srchstr.j.1=0 /* set matches to zero */
end
Return
/**************************************************************************/
/* Wait until scan program not in task list */
/**************************************************************************/
WaitScanDone:
do timer=1 /* allows iterate timer */
Address Command "status > "timerfile
foo=delay(delaytm) /* pause for command */
goodopen=open('IN',timerfile,'R')
if goodopen then do
do until eof('IN')
linein=readln('IN')
if pos(scanprog,linein)>0 then do
result=close('IN')
iterate timer /* keep looping */
end
end
result=close('IN')
leave timer
end
else do
infomsg='Couldnt open timerfile'
Call InfoMsg
end
end
Return
/******************************************************************************/
/* */
/* Display informationn about YAMTOOLS, YAM, MUIREXX. */
/* */
/******************************************************************************/
AboutProgs:
bc='\033b\033c'
nc='\033n\033c'
nl='\n'
nl2='\n\n'
ct='\033c'
Address YAM 'info title'
yamtitle=result
Address YAM 'info copyright'
yamcopy=result
txt.0=23
txt.1="\033cYAMTOOLS"
txt.2="\033cCopyright ©1997 by Dick Whiting"
txt.3="\033n"
txt.4="--------------------------------------------------------------------"
txt.5="\033n"
txt.6="=Standard Disclaimer: I wrote it, it works for me, I don't guarantee"
txt.7="=that it will do anything productive for anyone else, etc. etc. ;-)"
txt.8="\033n"
txt.9="=HOWEVER, if you DO find a use for it: I homeschool my kids and they"
txt.10="=would love a postcard from where EVER you live."
txt.11="\033n"
txt.12="=Instant GEOGRAPHY lesson;)"
txt.13="\033n"
txt.14="=POSTCARDS: Dick Whiting"
txt.15="= 28590 S. Beavercreek Rd."
txt.16="= Mulino, Oregon 97042"
txt.17="= USA"
txt.18="\033n"
txt.19="--------------------------------------------------------------------"
txt.20="\033n"
txt.21="\033cAddress Bug Reports or Comments to:"
txt.22="\033cDick Whiting <dwhiting@europa.com>"
txt.23="\033c28 March 1997"
select
when parm='YAM' then do
ab.title="About "||yamtitle||" "||yamcopy
aboutlist=FALSE
fontsize="ATTRS MUIA_FONT MUIV_Font_Big"
aboutmsg=bc||'!! T H A N K Y O U M A R C E L !!'
Call AboutWin
end
when parm='MUIREXX' then do
ab.title="About "||parm
aboutlist=FALSE
aboutmsg=ct||"!! Great Product - Register It !!"
Call AboutWin
end
otherwise do
ab.title="About "||parm
ab.desc="YamTools -- Add-on Tools For YAM"
ab.copy="Version 1.4 Copyright ©1997 by Dick Whiting"
ab.text1=yamtitle||' '||yamcopy
ab.text2="MuiRexx © Russell Leighton"
ab.text3="MUI © Stefan Stuntz"
aboutmsg=bc||ab.desc||nl||nc||ab.copy||nl||txt.19||nl||ab.text1||nl||ab.text2||nl||ab.text3
Call AboutWin
do i=1 to txt.0
list ID ABLST INSERT POS MUIV_List_Insert_Bottom STRING txt.i
end
list ID ABLST POS MUIV_List_Insert_Top
end
end
Return
/******************************************************************************/
/* Display window for ABOUT programs. */
/******************************************************************************/
AboutWin:
window ID YTABT TITLE '"'ab.title'"' MUIA_Window_DepthGadget FALSE,
MUIA_Window_DragBar FALSE MUIA_Window_PublicScreen screen
group
text fontsize LABEL aboutmsg
endgroup
if aboutlist then do
group
list ID ABLST
endgroup
end
group HORIZ
group
space HORIZ
endgroup
group
button PRESS COMMAND '"window ID YTABT CLOSE"' PORT YAMTOOLS,
LABEL "Ok"
endgroup
group
space HORIZ
endgroup
endgroup
endwindow
Return
/******************************************************************************/
/* Display ERROR message and EXIT. */
/******************************************************************************/
ErrorMsg:
window ID YTINF CLOSE
request ID ERRM GADGETS '"OK"' errmsg
if shutdown then do
Address YAMTOOLS "QUIT"
end
if ~goodconfig then do
group ID YTPGS LABELS 'Config'
end
exit
Return
/******************************************************************************/
/* Display information message and RETURN */
/******************************************************************************/
InfoMsg:
request ID INFOM GADGETS '"OK"' infomsg
Return
/******************************************************************************/
/* Simple information/error message window. */
/******************************************************************************/
InfoWindow:
window ID YTINF TITLE '"YAM Tools Info"' ATTRS MUIA_Window_PublicScreen screen,
MUIA_Window_SizeGadget FALSE MUIA_Window_DragBar FALSE,
MUIA_Window_DepthGadget FALSE
group
group
text ID STEXT HELP help.STEXT NODE node.STEXT LABEL infotext
endgroup
if showbusy then do
group
object CLASS '"Busy.mcc"' ATTRS MUIA_VertWeight 25
endgroup
end
if infobuttons ~='' then do
group HORIZ
group
space HORIZ
endgroup
group
radio ID SQUIT HELP help.SQUIT NODE node.SQUIT LABELS infobuttons
endgroup
group
space HORIZ
endgroup
endgroup
end
else do
group
space HORIZ 100
endgroup
end
endgroup
endwindow
Return
/******************************************************************************/
/* END OF ACTIVE CODE */
/******************************************************************************/